#pragma once

#include <Windows.h>

class Thread
{
	public:	
		Thread():		m_hThread(0), m_bTerminate(false) {}
		virtual			~Thread() {}

		void			terminate() { m_bTerminate = true; }
		bool			isTerminated() const { return m_bTerminate; }

		HANDLE			start();
		void			waitForTermination();
		virtual int		run()=0;
		virtual int		init()=0;

	protected:
		HANDLE			m_hThread;
		bool			m_bTerminate;


		static unsigned __stdcall threadFunc(void* param) {
			if (param)
				return ((Thread*)param)->run();
			return 1;
		}

};